var e = [ "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28" ], a = e.concat([ "29" ]), t = a.concat([ "30" ]), r = t.concat([ "31" ]);

function c(e) {
    return e < 10 ? "0" + e : "" + e;
}

function n(e, a) {
    a = a || 1;
    for (var t = [], r = e = e || 0; r <= a; r++) t.push(c(r));
    return t;
}

function s(c, n) {
    var s = c % 400 == 0 || c % 4 == 0 && c % 100 != 0, u = null;
    switch (n) {
      case "01":
      case "03":
      case "05":
      case "07":
      case "08":
      case "10":
      case "12":
        u = r;
        break;

      case "04":
      case "06":
      case "09":
      case "11":
        u = t;
        break;

      case "02":
        u = s ? a : e;
        break;

      default:
        u = [];
    }
    return u;
}

module.exports = {
    dateTimeData: function(e, a, t) {
        var r = [], u = [ [], [], [], [], [], [] ], o = new Date(), i = a || o.getFullYear(), f = t || o.getFullYear() + 3, g = function(e) {
            var a = e || new Date();
            return [ c(a.getFullYear()), c(a.getMonth() + 1), e = c(a.getDate()), c(a.getHours()), c(a.getMinutes()), c(a.getSeconds()) ];
        }(e);
        return u[0] = n(i, f), u[1] = n(1, 12), u[2] = s(g[0], g[1]), u[3] = n(0, 23), u[4] = n(0, 59), 
        u[5] = n(0, 59), u.forEach(function(e, a) {
            r.push(e.indexOf(g[a]));
        }), {
            dateTimeArray: u,
            dateTime: r
        };
    },
    getMonthDays: s,
    getLoopArray: n
};